/*
 * @Author: zhuxiaoyi
 * @Date: 2024-01-26 16:09:04
 * @LastEditor: zhuxiaoyi
 * @LastEditTime: 2024-07-02 15:45:18
 * @Description:
 */
import {
  Body,
  Controller,
  Del,
  Get,
  Inject,
  Param,
  Put,
  Query,
  Post
} from '@midwayjs/core';
import { GetTaskDto, changeStausDto, statusListenDto } from '../dto/TaskDto';
import { addGraphDto, updateGraphDto, nodeDto, eidtNodeParamsDto,pauseDto } from '../dto/GraphDto';
import { GetGraphListDto } from '../dto/GraphDto';
import { GraphService } from '../service/graph.service';

@Controller('/graph')
export class APIController {
  @Inject()
  graphService: GraphService;

  @Get('/getGraphs', { summary: '流程列表' })
  async getList(@Query() params: GetGraphListDto) {
    return await this.graphService.getGraphList(params);
  }

  @Get('/getGraph/:id', { summary: '流程列表' })
  async getGraph(@Param('id') id: number) {
    return await this.graphService.getGraph(id);
  }

  @Post('/addGraph', { summary: '新增算法流程' })
  async addGraph(@Body() params: addGraphDto) {
    return await this.graphService.addGraph(params)
  }

  @Put('/updateGraph', { summary: '编辑算法流程' })
  async updateGraph(@Body() params: updateGraphDto) {
    return await this.graphService.updateGraph(params)
  }

  @Get('/executeGraph/:id', { summary: '执行流程' })
  async executeGraph(@Param('id') id: number) {
    return await this.graphService.executeGraph(id);
  }

  @Del('/deleteGraph/:id', { summary: '删除流程' })
  async deleteGraph(@Param('id') id: number) {
    return await this.graphService.deleteGraph(id);
  }

  @Post('/getNodeParams/:id', { summary: '算法参数查询' })
  async getNodeParams(@Param('id') id: number, @Body() node: nodeDto) {
    return await this.graphService.getNodeParams(id, node.id);
  }
  @Put('/changePauseStatus/:id', { summary: '算法运行时是否暂停状态修改' })
  async changePauseStatus(@Param('id') id: number, @Body()params :pauseDto ) {
    return await this.graphService.changePauseStatus(id, params);
  }

  @Put('/updateNodeParams/:id', { summary: '编辑算法参数' })
  async updateNodeParams(@Param('id') id: number, @Body() params: eidtNodeParamsDto,) {
    return await this.graphService.updateNodeParams(id, params)
  }

  @Get('/getDynamicData/:id', { summary: '模板字符串' })
  async getDynamicData(@Param('id') id: number) {
    return await this.graphService.getDynamicData(id);
  }
  @Post('/editDynamicData/:id', { summary: '修改模板字符串' })
  async editDynamicData(@Param('id') id: number, @Body() Params: any) {
    return await this.graphService.editDynamicData(id, Params.dynamicData);
  }




}
